#include "version_shader.hpp"

#include <iostream>

#include "OpenLog.h"

Base_WindowCreate::Base_WindowCreate() : m_width(600), m_height(600)
{
    /* 初始化 GLFW */
    if (!glfwInit())
    {
        LOGE("Failed to initialize GLFW");
        exit(EXIT_FAILURE);
    }
    /* 当期OpenGL的版本号 主版本号.此版本号 */
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    /* 创建GLFW窗口 */
    GLFWwindow *window = glfwCreateWindow(m_width, m_height, "OpenGL - name", NULL, NULL);
    std::shared_ptr<GLFWwindow> window_shared(
        window, [](GLFWwindow *window) { /* 析构GLFW窗口 */
                 glfwDestroyWindow(window); });
    m_window = window_shared;
    glfwMakeContextCurrent(window);

    LOGI("OpenGL Version: %s", glGetString(GL_VERSION));
    LOGI("GLSL Version: %s", glGetString(GL_SHADING_LANGUAGE_VERSION));
    LOGI("Renderer: %s", glGetString(GL_RENDERER));
    LOGI("Vendor: %s", glGetString(GL_VENDOR));

    /* 初始化 GLEW */
    if (glewInit() != GLEW_OK)
    {
        LOGE("Failed to initialize GLEW");
        exit(EXIT_FAILURE);
    }
    glfwSwapInterval(1);
}

Base_WindowCreate::~Base_WindowCreate()
{
}
